<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<p>
			整数1：<input type="text" id="zheng1"/>
		</p>
		<p>
			整数2：<input type="text" id="zheng2" />
		</p>
		<button onclick="change('jia')">相加</button>
		<button onclick="change('jian')">相减</button>
		<button onclick="change('cheng')">相乘</button>
		<button onclick="change('chu')">相除</button>

		<p>
			结果：<input type="text" id="jie" />
		</p>
		
		<script>
			
			function change(e){
				var text1 = document.querySelector("#zheng1").value;
				text1 = Number(text1);
				var text2 = document.querySelector("#zheng2").value;
				text2 = Number(text2);
				switch(e){
					case 'jia':
					document.querySelector("#jie").value = text1 + text2;
					break;
					case 'jian':
					document.querySelector("#jie").value = text1 - text2;
					break;
					case 'cheng':
					document.querySelector("#jie").value = text1 * text2;
					break;
					case 'chu':
					document.querySelector("#jie").value = text1 / text2;
					break;
				}
			}
			
		</script>
	</body>
</html>
